/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model.creature.sprite.plugin;

import java.awt.Image;
import model.creature.DamageableCreature;
import model.creature.sprite.DefaultHealerSprite;
import model.creature.sprite.Sprite;
import model.game.GameInterface;
import model.utility.ImageUtility;

/**
 * Heals self and allies
 */
public class Healer extends DefaultHealerSprite {

  /**
   * Constructor
   */
  public Healer(GameInterface game) {
    super(game, game.getMaps().getField().getCellAt(1,1));
  }

  @Override
  public int getHiringPrice() {
    return 500 + getLevel() * 250;
  }

  @Override
  public String getName() {
    return "Healer";
  }

  @Override
  public String getDescription() {
    return "Lv: " + getLevel() + ", MaxHP: " + getMaxHP() + ", " +
    "It heals other sprites for " + getHealValue() + " damage. "
            + "Healing distance is " + healDistance() + ". "
            + "Upgrade increases HP, heal value, and sometimes attack distance." +
            " High leveled healers learned to heal multiple creatures.";
  }

  @Override
  public Image getImage() {
    return ImageUtility.loadImage("resources/pictures/sprite/healer/healer.png");
  }

  @Override
  public boolean canUpgrade() {
    if (getLevel() < 10) return true;
    return false;
  }

  @Override
  public int getUpgradeCost() {
    return getLevel() * 100 + 100;
  }

  @Override
  public int getMaxHP() {
    return 150 + getLevel() * 250;
  }

  /**
   * Retrieves the damage done by this creature
   */
  @Override
  public int getHealValue() {
    return 20 + getLevel() * 15;
  }

  /**
   * Retrieves attack distance
   */
  @Override
  public int healDistance() {
    if (getLevel() >= 10) return 6;
    if (getLevel() >= 8) return 5;
    if (getLevel() >= 6) return 4;
    if (getLevel() >= 4) return 3;
    if (getLevel() >= 2) return 2;
    return 1;
  }

  /**
   * Retrieves attack count
   */
  @Override
  public int getHealCount() {
    if (getLevel() >= 8) {
      return 2;
    }
    return 1;
  }

  @Override
  public boolean canHeal(DamageableCreature crt) {
    if (!(crt instanceof Sprite)) return false;
    if (crt.getHP() == crt.getMaxHP()) return false;
    return true;
  }

}
